/*
 * console.cpp
 *
 *  Created on: 7-ott-2008
 *      Author: fpistonesi
 */
/*

 Copyright (c) 2008-2009 Fabrizio Pistonesi

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

 */

#include "console.h"

Console::Console()
{
  dimension2d<u32> size = Device->getVideoDriver()->getScreenSize();
  GUIEnv = Device->getGUIEnvironment();
  Panel = GUIEnv->addStaticText(L"Console",rect<s32>(0,0,size.Width,0));
  InputBox = GUIEnv->addEditBox(L"",rect<s32>(0,0,size.Width,20),true,Panel);
  OutputBox = GUIEnv->addStaticText(L"",rect<s32>(0,20,size.Width,180),false,true,Panel);
  OutputBox->enableOverrideColor(true);
  OutputBox->setOverrideColor(SColor(255,255,255,255));

}

Console::~Console()
{

}

void Console::Show()
{
  dimension2d<u32> size = Device->getVideoDriver()->getScreenSize();
  u32 now = Device->getTimer()->getTime();
  u32 endTime = now + 250;
  while (Device->getTimer()->getTime() <= endTime)
    {
      s32 y = 180 * (Device->getTimer()->getTime() / endTime);
      Panel->setRelativePosition(rect<s32> (0, 0, size.Width, y));
    }
}

void Console::Hide()
{
  dimension2d<u32> size = Device->getVideoDriver()->getScreenSize();
  u32 now = Device->getTimer()->getTime();
  u32 endTime = now + 250;
  while (Device->getTimer()->getTime() <= endTime)
    {
      s32 y = 180 - 180 * (Device->getTimer()->getTime() / endTime);
      Panel->setRelativePosition(rect<s32> (0, 0, size.Width, y));
    }
}

